home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 4076 / 4076.xpi / chrome / addthis.jar / content / ContextMenu.js < prev    next >
Encoding:
Text File  |  2010-01-06  |  2.2 KB  |  70 lines

  1. var AddThis_ContextMenu = {
  2.  
  3.     init : function() {
  4.         AddThis_Util.dbg("ContextMenu.init: initting...");
  5.         AddThis_Util.dbg("ContextMenu.init: done.");
  6.     },
  7.     
  8.     prepare: function()
  9.     {
  10.         AddThis_Util.dbg("ContextMenu.prepare: go...");
  11.         
  12.         var url, title;
  13.         var mediaURL = 'mediaURL' in gContextMenu ? gContextMenu.mediaURL : gContextMenu.imageURL; 
  14.         if (gContextMenu.onLink === true && gContextMenu.onSaveableLink === true)
  15.         {
  16.             url = 'getLinkURL' in gContextMenu ? gContextMenu.getLinkURL() : gContextMenu.linkURL(); 
  17.             if (gContextMenu.onImage === true && gContextMenu.imageURL !== "")
  18.             {
  19.                 title = this._getTitleFromImage(gContextMenu.target);
  20.             }
  21.             else title = gContextMenu.linkText();
  22.             if (!title) title = "";
  23.         }
  24.         else if (gContextMenu.onImage === true && mediaURL !== "")
  25.         {
  26.             var urlObj = AddThis_Util.convertURLToObject(gBrowser.contentDocument.location.href);
  27.             url = AddThis_Util.resolveURL(urlObj.spec, mediaURL.toString());
  28.             title = this._getTitleFromImage(gContextMenu.target);
  29.             if (!title) title = "";
  30.         }
  31.         
  32.         
  33.         
  34.         AddThis_Util.dbg("ContextMenu.prepare: url: " + url + " title: " + title);
  35.         AddThis_Sharing.initShareMenu("at_contextMenuPopup", url, title);
  36.     },
  37.     
  38.     _getTitleFromImage: function(target)
  39.     {
  40.         var title="";
  41.         if (target.localName.toUpperCase() == "IMG")
  42.         {
  43.             title = target.getAttribute("title");
  44.             if (!title)
  45.             {
  46.                 title = target.getAttribute("alt");
  47.                 if (!title)
  48.                 {
  49.                     title = "";
  50.                 }
  51.             }
  52.         }
  53.         return title;
  54.      },
  55.     
  56.     
  57.     setVisibility: function()
  58.     {
  59.         AddThis_Util.dbg("ContextMenu.setVisibility: go...");
  60.         var cm = document.getElementById("at_contextMenu");
  61.         cm.setAttribute("hidden", AddThis_Util.getBooleanPref("extensions.addthis.contextmenu.disable",false));
  62.     },
  63.     
  64.     isVisible : function(doc) {
  65.         if (typeof doc == "undefined") doc = document;
  66.         var visible = !doc.getElementById("at_contextMenu").hidden;
  67.         AddThis_Util.dbg("ContextMenu.isVisible: " + visible);
  68.         return visible;
  69.     }
  70. };